package satir.command;

import satir.SatirGame;
import satir.player.Player;

/**
 * The Class RollDiceCmd.
 * 
 * @version 2.0 March 2012
 * @author Bill Chan
 */
public class RollDiceCmd implements Command {
	
	/** The satir game. */
	private SatirGame satirGame;
	
	/**
	 * Instantiates a new roll dice cmd.
	 *
	 * @param satirGame the satir game
	 */
	public RollDiceCmd(SatirGame satirGame){
		this.satirGame = satirGame;
	}
	
	/* (non-Javadoc)
	 * @see stair.command.PlayerCmd#execute()
	 */
	public void execute(){
		Player targetPlayer = satirGame.getCurrentPlayer();
		//generate a random dice
		int rollDiceMovement = 1+(int) (Math.random() * 6);
		//move
		targetPlayer.addMovement(rollDiceMovement);
		//print out result
		System.out.println(targetPlayer.getName()+" roll a number of "+rollDiceMovement+"\n");
		System.out.println("Here is the new position");
		satirGame.getBoard().showBoard();
		
		//This is the event for the cell appear:
		//We need to discuss and there may be changes
		targetPlayer.getCurrentCell().cellAction(targetPlayer);
	}
}